<?php
$comments = $this->comments;
$article = $this->article;
$isLogged = \Zend_Auth::getInstance()->hasIdentity();
?>


<?php foreach ($comments as $comment): ?>
<div
    style="margin-left: 30px;" <?if ($comment['rating'] >= 3) echo "class='goodcomment'"; if ($comment['rating'] <= -3) {
    echo "class='badcomment'";
}?>>
    <?if ($comment['rating'] <= -3) {
    echo "<a href='#' class='managecomment'>Показать комментарий</a>";
}?>
    <table class="comment" width="590">
        <tr>
            <td>Пользователь <i><?php echo $this->escape($comment['email']); ?></i> оставил комментарий:


            </td>
            <td></td>
        </tr>
        <tr>
            <td style="width: 540px;">
                <? if ($comment['isBlocked']): ?>
                Комментарий удален.
                <? else: ?>
                <?php echo $this->escape($comment['text']) ?>
                <? endif; ?>
            </td>
            <td style="text-align: center">   <span><?php // на span висит js ?>
                <?php if ($comment['votable']): ?>
                    <a href="/comments/rate/comment/<?php echo $comment['id'] ?>/value/1" class="comment-rate"> + </a>
                    <?php endif; ?>

                <?php echo $comment['rating'] ?>

                <?php if ($comment['votable']): ?>
                    <a href="/comments/rate/comment/<?php echo $comment['id'] ?>/value/-1" class="comment-rate"> - </a>
                    <?php endif; ?>
                                </span>
            </td>
        </tr>
    </table>

    <br/>
    <span style="padding-bottom: 20px;" class="addcomment">
        <? if ($isLogged): ?>
        <a href="#" id="<?php echo $this->commentId($article, $comment['id']) ?>" class="comment-form">Добавить
            комментарий</a>
        <? endif; ?>
        </span>
    <hr>
    <?php if (count($comment['children'])): ?>
    <?php echo $this->partial('/index/_comments.phtml', array('comments' => $comment['children'], 'article' => $article)) ?>
    <?php endif; ?>
</div>
<?php endforeach; ?>
